package com.ykt.model;


import com.jfinal.plugin.activerecord.Page;

import java.util.List;
import java.util.Map;

public class Category extends BaseModel<Category> {
	private static final long serialVersionUID = 1L;

	public static final String pid = "pid";
    public static final String market_id = "market_id";
    public static final String icon = "icon";
    public static final String seq = "seq";

    public static final Category dao = new Category();

    @Override
    public Page<Category> pageFindModel(int pageNumber, int rows, Map<String, String> paramMap) {
        String select = "SELECT c.*, m.name marketName ";
        String sqlExceptSelect = " FROM category c left join market m on c.market_id=m.id ";
        String sqlOrderBy = " ORDER BY c.seq ";
        paramMap.put(OB, sqlOrderBy);
        return this.pageFindModel(select, sqlExceptSelect, pageNumber, rows, paramMap);
    }
    
    public List<Category> findByPid(int marketId, int pid){
        String sql = "select * from category where market_id=? and pid=? order by seq ";
        return this.find(sql, marketId, pid);
    }

}
